package Lee_code;

public class Lee_129 {
    int res=0;
    public int sumNumbers(Lee_337.TreeNode root) {
        int cur_sum=0;
        dfs(root, cur_sum);
        return res;
    }

    private void dfs(Lee_337.TreeNode root, int curSum) {
        //该店为叶子节点
        if (root.left==null && root.right==null)
            res = curSum*10 + root.val;

        if (root.left != null)
            dfs(root.left, curSum*10 + root.val);

        if (root.right != null)
            dfs(root.right, curSum*10 + root.val);
    }
}
